$(document).ready(function() {
	/* zebra */
	$(".zebra tr:odd").addClass("odd");
	$(".zebra tr:even").addClass("even");
	//$('#page_effect').fadeIn(1000);

	$(".confirm tr").addClass("confirm"); //confirm sayfaları tek renk olacak

	//tum inputlarda autocomplete kapatildi
	$('input[type=text]').attr('autocomplete', 'off');
	$('input[type=password]').attr('autocomplete', 'off');

	$("#bodyForm\\:download").click(function(e){
	    $(this).addClass("e-clicked");
	});

	$("#bodyFormsuz\\:download").click(function(e){
	    $(this).addClass("e-clicked");
	});

	$("form").submit(function(e) {
		//alert('1');
		if($(this).find(".e-clicked").attr("id") !== 'bodyForm:download' && $(this).find(".e-clicked").attr("id") !== 'bodyFormsuz:download'){
			//alert('2');
			//$('#page_effect').fadeIn(2000);
			loading.show();
		}
	});

	$.mask.masks = $.extend($.mask.masks, {
		'alpha'  :    {mask: '#', type: 'repeat' }
		  //other_msk:   { mask: '6666' },
		  //another_one: { mask: '7777', type:'reverse' }
	});

	//mask icin eklendi
	$('input[type="text"]').setMask();


	/*var masks = {
			'alpha':		'9'
			//pint:     /[\d]/,
			//'int':    /[\d\-]/,
			//pnum:     /[\d\.]/,
			//money:    /[\d\.\s,]/,
			//num:      /[\d\-\.]/,
			//hex:      /[0-9a-f]/i,
			//email:    /[a-z0-9_\.\-@]/i,
			//alpha:    /^[a-z\sığüşöç]+$/i,
			//alphanum: /[a-z0-9_]/i
			//date: /(0[1-9]|[12][0-9]|3[01])[/](0[1-9]|1[012])[/]([0-9]{4})/g
		};


	$('input[type="text"]').bind('focus', function(e) {
		if(typeof masks[$(this).attr("alt")] !== "undefined"){
			$(this).mask(masks["alpha"]);
		}
	});*/


	/*$('input[type="text"]').bind('copy', function(e) {
        alert('copying text!');
    });
    $('input[type="text"]').bind('paste', function(e) {
        alert('pasting text!');
    });
    $('input[type="text"]').bind('cut', function(e) {
        alert('cut text!');
    });*/

    /*$('input[type="text"]').bind('keypress change paste', function(e) {
        alert(e.type + ' text!');
    });*/


	/*var masks = {
		//pint:     /[\d]/,
		//'int':    /[\d\-]/,
		//pnum:     /[\d\.]/,
		//money:    /[\d\.\s,]/,
		//num:      /[\d\-\.]/,
		//hex:      /[0-9a-f]/i,
		//email:    /[a-z0-9_\.\-@]/i,
		alpha:    /^[a-z\sığüşöç]+$/i,
		//alphanum: /[a-z0-9_]/i
		date: /(0[1-9]|[12][0-9]|3[01])[/](0[1-9]|1[012])[/]([0-9]{4})/g
	};*/


	 /*$this.bind('keydown.mask', {func:maskObj._onKeyDown, thisObj:maskObj}, maskObj._onMask)
     .bind('keypress.mask', {func:maskObj._onKeyPress, thisObj:maskObj}, maskObj._onMask)
     .bind('keyup.mask', {func:maskObj._onKeyUp, thisObj:maskObj}, maskObj._onMask)
     .bind('paste.mask', {func:maskObj._onPaste, thisObj:maskObj}, maskObj._onMask)
     .bind('focus.mask', maskObj._onFocus)
     .bind('blur.mask', maskObj._onBlur)
     .bind('change.mask', maskObj._onChange);*/


	/*$('input[type="text"]').bind('keypress change paste', function(e) {
		if(typeof masks[$(this).attr("alt")] !== "undefined"){

			if(e.type === 'keypress'){
				var c = getCharCode(e), cc = String.fromCharCode(c);//, ok = true;
				if(!masks[$(this).attr("alt")].test(cc))
				{
					e.preventDefault();
				}

			}else if(e.type === 'paste'){
				if(!masks[$(this).attr("alt")].test($(this).val()))
				{
					$(this).val("");
				}
			}
		}
	});

	var getKey = function(e)
	{
		var k = e.keyCode || e.charCode;
		return $.browser.safari ? (SafariKeys[k] || k) : k;
    };

	var getCharCode = function(e)
	{
		return e.charCode || e.keyCode || e.which;
	};

	var isNavKeyPress = function(e)
	{
		var k = e.keyCode;
		k = $.browser.safari ? (SafariKeys[k] || k) : k;
		return (k >= 33 && k <= 40) || k == Keys.RETURN || k == Keys.TAB || k == Keys.ESC;
	};

    var isSpecialKey = function(e)
	{
		var k = e.keyCode;
		var c = e.charCode;
		return k == 9 || k == 13 //|| (k == 40 && (!$.browser.opera || !e.shiftKey))
			|| k == 27 ||
			k == 16 || k == 17 ||
			(k >= 18 && k <= 20) ||
			($.browser.opera && !e.shiftKey && (k == 8 || (k >= 33 && k <= 35) || (k >= 36 && k <= 39) || (k >= 44 && k <= 45)))
			;

    };*/

});



function validateDate(frm, minDateParam, maxDateParam){
	bluredElement = document.getElementById(frm.id);
	bluredElementValue = bluredElement.value;

	if(bluredElementValue != ""){
	    var reGex = /(0[1-9]|[12][0-9]|3[01])[/](0[1-9]|1[012])[/]([0-9]{4})/g;

		var result=reGex.test(bluredElementValue);
		//alert("Returned value: " +  result);
	    if(!result){
	       alert("Girilen tarih yanl\u0131\u015Ft\u0131r\! L\u00FCtfen tekrar deneyiniz.");
		   document.getElementById(frm.id).value = '';
		   return false;
	    }

	    var elem = bluredElementValue.split('/');
		day = elem[0];
		month = elem[1];
		year = elem[2];

		bluredElementValue = month + '/' + day + '/' + year;

		//alert(bluredElementValue);

	    var selectedDate = new Date(bluredElementValue);

	    if(minDateParam != ""){
			var minDateRange = new Date(Number(minDateParam));
			//alert(minDateRange + ' - ' +  selectedDate)
			if (tarihKarsilastir(minDateRange, selectedDate) > 0) {
				document.getElementById(frm.id).value = dateToString(minDateRange, "dd/MM/yyyy");
				return false;
			}
		}

	    if(maxDateParam != ""){
			var maxDateRange = new Date(Number(maxDateParam));
			//alert(maxDateRange + ' - ' +  selectedDate)
			if (tarihKarsilastir(maxDateRange, selectedDate) < 0) {
				document.getElementById(frm.id).value = dateToString(maxDateRange, "dd/MM/yyyy");
				return false;
			}
		}
	}
 }